package day06;

import java.util.Random;

public class MethodDemo {

    public static void main(String[] args) {

        say();
        say("czd");
        say("asd",456);

/*        sayHello2("czd", 25);
        sayHello2("asd", 64);

 */


/*        int[] c = generateArray(10,100);

        System.out.println("源数组为：");
        for (int i=0;i<c.length;i++){
            System.out.println(c[i]);
        }
        System.out.println("数组的长度为：" + c.length);
        System.out.println("over");

 */
 /*       //say();//调用say方法
        //sayHi("陈子冬");
        //sayHello("陈子冬", 25);
        int a = sum(5, 6);
        System.out.println(a);

        int m = 5, n = 7;
        int b = sum(m, n);//传的是m和n里面的数
        System.out.println(b);

 */

    }


    public static void sayHello2(String name, int age) {
        if (age >= 60) {
            return;
        }
        System.out.println("大家好，我叫" + name + ",今年" + age + "岁了。");
    }

    public static int[] generateArray(int len, int max) {
        Random rand = new Random();
        int arr[] = new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = rand.nextInt(max + 1);//包含max,0到max的数
        }
        return arr;
    }


    public static int sum(int num1, int num2) {
        int num = num1 + num2;
        return num;//返回的是num里面的那个数:num1+num2
    }

    public static void say(String name, int age) {
        System.out.println("大家好，我是" + name + ",今年" + age + "岁啦。");
    }

    //有参数，无返回值
    public static void say(String name) {
        System.out.println("大家好，我是" + name + ",今年25岁了。");
    }

    //无参，无返回值
    public static void say() {
        System.out.println("大家好。");
    }

}
